package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.ConsutationModel;
import com.banshuibao.bsb_android.util.PriceUtil;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/22.
 */

public class ConsultationAdapter extends MineBaseAdapter<ConsutationModel.DataBean> {

    public ConsultationAdapter(Context context, List<ConsutationModel.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
    }

    @Override
    protected void bindData(ViewHolder holder, ConsutationModel.DataBean item) {

        TextView content = (TextView) holder.getView(R.id.item_tab_content);
        TextView date = (TextView) holder.getView(R.id.item_tab_date);
        TextView status = (TextView) holder.getView(R.id.item_tab_status);
        TextView money = (TextView) holder.getView(R.id.item_tab_money);

        content.setText(item.getContent());
        String time = null;
        if (item.getCreateDate() != 0) {
            time = TimeUtil.format(item.getCreateDate());
        } else {
            time = "";
        }
        date.setText(time);
        money.setText("¥" + PriceUtil.FormatDecimal(item.getPrice()));
        //判断是否有回答
        String answerUserId = item.getAnswerUserId();
        //我问的状态
        String itemStatus = item.getStatus();
        if (!TextUtils.isEmpty(answerUserId)){
            if (!TextUtils.isEmpty(itemStatus)) {
                if (itemStatus.equals("1")) {
                    status.setText("已采纳");
                } else {
                    status.setText("未采纳");
                }
            }
        }else {
            status.setText("未回答");
        }
    }
}
